import type { LoaderFunctionArgs } from "@remix-run/cloudflare";
import { json, redirect } from "@remix-run/cloudflare";
import { getSession, destroySession } from "~/sessions";
import { getRecords } from "~/db/d1-data";

export async function action({ request, context }: LoaderFunctionArgs) {
	const method = request.method;

	const session = await getSession(request.headers.get("Cookie"));

	if (session.has("user")) {
		const userId = session.get("user")?.id;
    const result = await getRecords(context.cloudflare.env.D1DATA, "feeds", { userId })
	} else {
		await destroySession(session);
		return redirect("/login");
	}
}
